package com.hdl.client;

import com.hdl.pojo.User;
import com.hdl.service.IHelloService;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

/**
 * 类名 RmiClient
 * 描述 TODO
 *
 * @author hedonglin
 * @version 1.0
 * @date 2020/6/9 12:38
 */
public class RmiClient {
    public static void main(String[] args) throws RemoteException, NotBoundException, MalformedURLException {
        // 从注册表中获取远程对象
        IHelloService helloService = (IHelloService) Naming.lookup("//127.0.0.1:8888/hello");

        // 2、准备参数
        User user = new User("老王", 19);

        // 调用请求
        String result = helloService.sayHello(user);

        System.out.println(result);
    }
}
